package Events;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import Factory.ObjectFactory;


public class EventFactory {
	private String docProperties = "docs\\events.properties";
	private Properties properties;
	public EventFactory()
	{
		properties = new Properties();
		  try {
		      properties.load(new FileInputStream(docProperties));
		  } catch (IOException e) {
		  	System.out.println("Cannot found events.properties");
		  }
	}
	public GenericEvent createEvent(TypeEvent type)
	{
		
		if(TypeEvent.Alarm.equals(type))
		{
			Alarm evento;
			evento = (Alarm)ObjectFactory.fabricar(properties.getProperty("alarm"));
			return evento;
		}
		else if(TypeEvent.Appointment.equals(type))
		{
			Appointment evento;
			evento = (Appointment) ObjectFactory.fabricar(properties.getProperty("appointment"));
			return evento;
		}
		else if(TypeEvent.Task.equals(type))
		{
			Task evento;
			evento = (Task) ObjectFactory.fabricar(properties.getProperty("task"));
			return evento;
		}
		else if(TypeEvent.MoodleEvent.equals(type))
		{
			MoodleEvent evento;
			evento = (MoodleEvent) ObjectFactory.fabricar(properties.getProperty("moodleEvent"));
			return evento;
		}
		return null;
	}
}
